<?php

/**
* <class description>
* 
* @author
* @link
*/

class Big_images extends Controller
{
    public function __construct()
    {
        parent::Controller();      

    }    

    public function installations()
    {

        $this->load->model('gallerymodel');  
        $data['folder'] = base_url().UPLOADS_FOLDER.INSPIRATIONALGALLERY_IMG_FOLDER;
        $data['big_images'] =  $this->gallerymodel->get_list("Image_Gallery AS Big_Image");
                                    
        $this->_pass_to_view($data);

    } 
    public function all_products()
    {
        
        $this->load->model('productsmodel'); 
        $data['folder'] = base_url().UPLOADS_FOLDER.PRODUCT_TOP_GALLERY_IMG_FOLDER;
        $data['big_images'] = $this->productsmodel->get_big_img_all_products();  

        $this->_pass_to_view($data);

    }
    public function one_off_products()
    {
        $data['folder'] = base_url().UPLOADS_FOLDER.PRODUCT_TOP_GALLERY_IMG_FOLDER;
        $data['big_images'] = $this->productsmodel->get_big_img_one_off();  

        $this->_pass_to_view($data);

    }     
    public function single_product($id = FALSE)
    {
        $data['folder'] = base_url().UPLOADS_FOLDER.PRODUCT_TOP_GALLERY_IMG_FOLDER;
        $data['big_images'] = $this->productsmodel->get_big_img_single_product($id);  

        $this->_pass_to_view($data);

    }
    public function products_by_application($id = FALSE)
    {
        $data['folder'] = base_url().UPLOADS_FOLDER.PRODUCT_TOP_GALLERY_IMG_FOLDER;
        $data['big_images'] = $this->productsmodel->get_big_img_by_application($id);  

        $this->_pass_to_view($data);

    }
    public function products_by_category($id = FALSE)
    {
        $data['folder'] = base_url().UPLOADS_FOLDER.PRODUCT_TOP_GALLERY_IMG_FOLDER;
        $data['big_images'] = $this->productsmodel->get_big_img_by_category($id);  

        $this->_pass_to_view($data);

    }  
    private function _pass_to_view($data = array())
    {
        
        shuffle($data['big_images']);
        $data['big_images'] = array_slice($data['big_images'],0,6);   

        if(!empty($data['big_images']))
            $this->load->view("smooth_gallery", $data);

    }


    public function products($data = array())
    {

        if (empty($data))
            $data = $this->productsmodel->get_all_products_grouped_in_categories();

        if (array_key_exists('Big_Image',$data)){   // single item

            $items[] = base_url().UPLOADS_FOLDER.PRODUCT_TOP_GALLERY_IMG_FOLDER.$data['Big_Image'];

        } else if (array_key_exists('items',$data[0])){    // grouped list of items
            
            foreach($data as $group){
                foreach($group['items'] as $item){
                    $items[] = base_url().UPLOADS_FOLDER.PRODUCT_TOP_GALLERY_IMG_FOLDER.$item['Big_Image'];

                }    
            }

        } else {    // list of items, ungrouped
            
            foreach($data as $item){
                $items[] = base_url().UPLOADS_FOLDER.PRODUCT_TOP_GALLERY_IMG_FOLDER.$item['Big_Image'];
            }

        }

        shuffle($items);
        $data['big_images'] = array_slice($items,0,6);
                                                 
        if(!empty($data['big_images']))
        $this->load->view("smooth_gallery", $data);

    }

}

/* End of file users.php */
/* Location: ./system/application/modules/frontoffice/controllers/home.php  */ 